<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div class="box">盒子1</div>
    <div class="box">盒子2</div>
    <div id="nav">
        <ul>
            <li>首页</li>
            <li>产品</li>
        </ul>
    </div>

    <script>
        var classes = document.getElementsByClassName('box');
        console.log(classes);
        //querSelector 返回指定选择器的第一个元素对象 切记 里面的选择器需要加符号.box #nav等
        var firstBox = document.querySelector('.box')
        console.log(firstBox);
        var nav = document.querySelector('#nav');
        console.log(nav);
        var li = document.querySelector(li);
        console.log(li);

        //querSelectorAll 指定选择器的所有对象
        var allBox = document.querySelectorAll('box');
        console.log(allBox);
    </script>
</body>

</html>